package com.yunxi.core.page;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.yunxi.core.base.Constant;

import java.util.Map;

public class PageHelperPlus extends PageHelper {
    public static Page startPage(Map<String,Object> params){
        int page_no;
        int page_size;

        if(params.get("pageNum")==null){
            page_no = 1;
        }else{
            page_no = Integer.valueOf(params.get("pageNum").toString());
        }
        if(params.get("pageSize")==null){
            page_size = Constant.PAGE_SIZE;
        }else{
            page_size = Integer.valueOf(params.get("pageSize").toString());
        }
        return startPage(page_no,page_size);
    }

    public static Page startPage(Integer pageNum,Integer pageSize){
        if(pageNum==null)
            pageNum = 1;

        if(pageSize==null)
            pageSize = Constant.PAGE_SIZE;

        return PageHelper.startPage(pageNum,pageSize);
    }
}
